package com.the_last.controller;

import com.the_last.service.DashboardService;
import com.the_last.utils.Result;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/dashboard")
@RequiredArgsConstructor
public class DashboardController {
    
    private final DashboardService dashboardService;
    
    @GetMapping("/statistics")
    @PreAuthorize("hasAuthority('DASHBOARD_QUERY')")
    public Result getStatistics() {
        return dashboardService.getStatistics();
    }
    
    @GetMapping("/weekly-reservations")
    @PreAuthorize("hasAuthority('DASHBOARD_QUERY')")
    public Result getWeeklyReservations(
            @RequestParam(required = false) String startDate,
            @RequestParam(required = false) String endDate) {
        return dashboardService.getWeeklyReservations(startDate, endDate);
    }
}